home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / UTILITY / DO1002.ARJ / IF.SCR < prev    next >
Text File  |  1991-12-28  |  6KB  |  166 lines

  1. .pg wi full clr
  2.     »cy«COMMAND NAME»gray«: »%t« Compare »ye«
  3.  
  4.     /IF {value1} {EQ|LT|GT|NE|GE|LE|LK} {value} [[{else label}][ ASIS]]
  5. /cw
  6.     Compare examines two values as:
  7.  
  8.          »cy«EQ»gray« - »cy«{value1}»#« equal to »cy«{value}
  9.          »cy«LT»gray« - »cy«{value1}»#« less than »cy«{value}
  10.          »cy«GT»gray« - »cy«{value1}»#« greater than »cy«{value}
  11.          »cy«NE»gray« - »cy«{value1}»#« not equal to »cy«{value}
  12.          »cy«GE»gray« - »cy«{value1}»#« greater than or equal to »cy«{value}
  13.          »cy«LE»gray« - »cy«{value1}»#« less than or equal to »cy«{value}
  14.          »cy«IN»gray« - »cy«{value1}»#« appears in »cy«{value}
  15.          »cy«LK»gray« - »cy«{value1}»#« matches the pattern in »cy«{value}»#«
  16.          »cy«NL»gray« - »cy«{value1}»#« does not match the pattern in »cy«{value}»#«
  17. .pg clr
  18.     Compare evaluates »cy«{value}»#« and »cy«{value1}»#« as numeric fields if
  19.     »c 132 0«BOTH»#« fields are numeric or formulae which evaluate to numeric
  20.     fields. Otherwise, the fields are evaluated as Text values.
  21.     Formula symbols and functions allowed are the same as the
  22.     »bo«/MATH»#« command.
  23.  
  24.     If the comparison is »gr«TRUE»#« then execution continues at the
  25.     next line in the script. Otherwise, »%t«DO»#« branches to the
  26.     »cy«{else label}»#«. If the »cy«{else label}»#« is omitted, »ye«DO»#« branchs
  27.     to the label "»cy«:ENDIF»#«" when the comparison is »re«FALSE»#«.
  28.  
  29.     Variables appearing in »cy«{value}»#« and »cy«{value1}»#« are expanded.
  30.     Both variables are converted to »c 12 0«uppercase»#« unless the "»cy«ASIS»#«"
  31.     token is included.
  32. .pg clr
  33.     Here are some examples. First, we'll set text variable 1, zero
  34.     counter 2 and use the »bo«/MATH»#« statement to set Result variable 3
  35.     then compare them.
  36. |/SET Name Fred
  37. |/Math Num2 10
  38. |/MATH Num3 10*2
  39. .clr
  40.     Now that we have these we can use the »bo«/IF»#« command to compare
  41.     these values:
  42.  
  43.         Text Variable Name         »gray«= »ye«%Name»#«
  44.         Number Variable Num2       »gray«= »ye«%Num2(@@@)»#«
  45.         Number Variable Num3       »gray«= »ye«%Num3(###)»#«
  46. .wi 1 12 79 22
  47. |/IF %Name EQ John COMP1
  48. :COMP1
  49.     Since »bo«FRED»#« was »re«NOT»#« »cy«EQ»#«ual to »bo«JOHN»#«, »%t«DO»#« branched to the label
  50.     »cy«COMP1»#«. Notice that "Fred" and "John" were converted to upper
  51.     before the comparison was made.
  52. .pg clr
  53. |/IF %Num2 NE 05 COMP2
  54.     »ye«Num = %Num2(##)»#«. Since this isn't equal to »bo«05»#«, »%t«DO»#«
  55.     continued to the next statement. »re«NOTE»gray«:»#« since both strings
  56.     are numeric, this is a »c 142 0«NUMERIC»#« comparison.
  57. .pg clr
  58. :COMP2
  59. |/IF %Num3(@@@) GE 10*3
  60. :ENDIF
  61.     Like the Counter variable comparison, this one is a NUMERIC
  62.     comparison. Since Num3 is less than 30 (10*3)
  63.      -- i.e. %Num3(@@@) -- the comparison is false and the
  64.     statement branches to the label ":ENDIF"
  65.  
  66. .pg wi 1 5 79 24 clr
  67.     The »ye«LK»#« (like) operand allows you to use "»gr«wildcard»#«" characters
  68.     to test a field.  The following wildcard characters can be
  69.     used with this operator:
  70.  
  71.  
  72.       »wh«?   »cy«= »#«Any character
  73.       »wh«#   »cy«= »#«Any integer
  74.       »wh«\   »cy«= »#«next character is literal
  75.       »wh«*   »cy«= »#«any string of characters
  76.       »wh«[]  »cy«= »#«Groups characters inclusive
  77.       »wh«[~] »cy«= »#«Groups characters exclusive
  78.       »wh«U   »cy«= »#«Any uppercase letter
  79.       »wh«L   »cy«= »#«any lower case letter
  80.       »wh«@   »cy«= »#«Any alphabetic character
  81.       »wh«{|} »cy«= »#«Groups of phrases
  82.       »wh«>   »cy«= »#«goto end of phrase
  83.  
  84. /BOX 4 9 42 21 14 12 " Wildcard Characters "
  85. /PAGE 25
  86. .wi 44 9 80 24
  87. Here are some examples
  88. of the use of wildcards
  89. in »%t«/IF»#« commands.  They
  90. are similar, but more
  91. powerful than the
  92. wildcards which
  93. can be used in »cy«DOS»#«
  94. commands.
  95. .pg clr
  96. "»wh«ABC»+re«?»#«"  will match "»cy«ABC»#«" and any
  97.         other single character.
  98.  
  99.         It will match "»cy«ABCD»#«" or
  100.         "»#«ABC$»#«" but not "»re«ABC»#«" or
  101.         "»re«ABCDE»#«" because they are
  102.         too short or too long.
  103. .pg clr
  104. "»wh«ABC»+re«#»#«"  will match "»gr«ABC»#«" and any
  105.         »ye«integer»#« (»cy«0-9»#«).
  106.  
  107.         It will match "»cy«ABC1»#«" or
  108.         "»cy«ABC3»#«", but not "»cy«ABCD»#«"
  109.         or "»re«ABC12»#«".
  110. .pg clr
  111. "»wh«ABC»+re«*»#«"  will match any string that
  112.         starts with "»cy«ABC»#«".
  113.  
  114.         It will match "»cy«ABC»#«", "»cy«ABCD»#«"
  115.         or "»cy«ABC1234$@@»#«", but not
  116.         "»ye«BDF»cy«1234»#«".
  117. .pg clr
  118. "»+re«*»wh«XYZ»#«"  Unlike »cy«DOS»#«, »%t«DO»#« can handle
  119.         the "»re«*»#«" at this start of
  120.         the phrase.
  121.  
  122.         This example will match any
  123.         string ending in "»gr«XYZ»#«".
  124. .pg clr
  125. "»+re«*»wh«DEF»+re«*»#«"  Will match a string with
  126.          "»gr«DEF»#«" anywhere in it.
  127. .pg clr
  128. "»wh«ABC»+re«[»wh«D»+re«-»wh«F»+re«,»wh«K»+re«]»#«"
  129.  
  130.         Will match any phrase
  131.         starting with "»cy«ABC»#«" and
  132.         ending with "»gr«D»#«", "»gr«E»#«",
  133.         "»gr«F»#«" or "»gr«K»#«".
  134. .pg clr
  135. "»wh«ABC»+re«[~»wh«D»+re«-»wh«F»+re«,»wh«K»+re«]»#«"
  136.  
  137.         Will match any phrase
  138.         starting with "»cy«ABC»#«" which
  139.         does NOT end in "»cy«D»#«", "»cy«E»#«",
  140.         "»cy«F»#«" or "»cy«K»#«".
  141. .pg clr
  142. "»+re«{»wh«ABC»+re«|»wh«DEF»+re«|»wh«GHI»+re«}»wh«K»#«"
  143.  
  144.         Will match "»cy«ABCK»#«",
  145.         "»cy«DEFK»#«" or "»cy«GHIK»#«".
  146.  
  147.         The phrases do »re«NOT»#« have
  148.         to be the same length.
  149. .pg clr
  150. "»wh«A»+re«>»wh«ED»#«"  Will match any phrase that
  151.         starts with "»cy«A»#«" and ends in
  152.         "»cy«ED»#«".
  153.  
  154.         It will match "»gr«AED»#«" or
  155.         "»gr«ABLE BODIED»#«".
  156. .pg -24 wi 1 5 79 24 clr
  157.     The »ye«LK»#« operator can generate very complex comparisons.
  158.  
  159.     The »re«NL»#« (»wh«Not Like»#«) operator is he opposite of the »ye«LK»#« operator
  160.     and is »cy«TRUE»#« when the expressions do »+re«not»#« match.
  161.  
  162.     Experiment with these operators to find their true power.
  163.  
  164. :END
  165. /ENDEXEC CLEAR
  166.